package com.ruoyi.business.service.impl;

import java.util.List;

import com.ruoyi.common.utils.BarCodeUtils;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.WmsInventoryRecordMapper;
import com.ruoyi.business.domain.WmsInventoryRecord;
import com.ruoyi.business.service.IWmsInventoryRecordService;

/**
 * 盘点单Service业务层处理
 *
 * @author ruoyi
 * @date 2024-01-21
 */
@Service
public class WmsInventoryRecordServiceImpl implements IWmsInventoryRecordService
{
    @Autowired
    private WmsInventoryRecordMapper wmsInventoryRecordMapper;

    /**
     * 查询盘点单
     *
     * @param id 盘点单主键
     * @return 盘点单
     */
    @Override
    public WmsInventoryRecord selectWmsInventoryRecordById(Long id)
    {
        WmsInventoryRecord wmsInventoryRecord = wmsInventoryRecordMapper.selectWmsInventoryRecordById(id);
        if (wmsInventoryRecord != null) {
            wmsInventoryRecord.setBarCode(BarCodeUtils.barCodeImageBase64(wmsInventoryRecord.getInventoryNo()));
        }
        return wmsInventoryRecord;
    }

    /**
     * 查询盘点单列表
     *
     * @param wmsInventoryRecord 盘点单
     * @return 盘点单
     */
    @Override
    public List<WmsInventoryRecord> selectWmsInventoryRecordList(WmsInventoryRecord wmsInventoryRecord)
    {
        return wmsInventoryRecordMapper.selectWmsInventoryRecordList(wmsInventoryRecord);
    }

    /**
     * 新增盘点单
     *
     * @param wmsInventoryRecord 盘点单
     * @return 结果
     */
    @Override
    public int insertWmsInventoryRecord(WmsInventoryRecord wmsInventoryRecord)
    {
        wmsInventoryRecord.setCreateTime(DateUtils.getNowDate());
        return wmsInventoryRecordMapper.insertWmsInventoryRecord(wmsInventoryRecord);
    }

    /**
     * 修改盘点单
     *
     * @param wmsInventoryRecord 盘点单
     * @return 结果
     */
    @Override
    public int updateWmsInventoryRecord(WmsInventoryRecord wmsInventoryRecord)
    {
        wmsInventoryRecord.setUpdateTime(DateUtils.getNowDate());
        return wmsInventoryRecordMapper.updateWmsInventoryRecord(wmsInventoryRecord);
    }

    /**
     * 批量删除盘点单
     *
     * @param ids 需要删除的盘点单主键
     * @return 结果
     */
    @Override
    public int deleteWmsInventoryRecordByIds(Long[] ids)
    {
        return wmsInventoryRecordMapper.deleteWmsInventoryRecordByIds(ids);
    }

    /**
     * 删除盘点单信息
     *
     * @param id 盘点单主键
     * @return 结果
     */
    @Override
    public int deleteWmsInventoryRecordById(Long id)
    {
        return wmsInventoryRecordMapper.deleteWmsInventoryRecordById(id);
    }
}
